# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer:
pkgname=ocaml-result
_pkgname=result
pkgver=1.4
pkgrel=1
pkgdesc="Compat result type"
url="https://github.com/janestreet/result"
arch="all !x86 !armhf !armv7 !s390x !mips !mips64"  # limited by ocaml
license="BSD-3-Clause"
depends="ocaml-runtime"
makedepends="dune ocaml ocaml-findlib opam"
options="!check"  # no tests provided
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/janestreet/$_pkgname/archive/$pkgver/result-$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

build() {
	jbuilder build @install
}

package() {
	mkdir -p "$pkgdir"/usr/lib/ocaml
	jbuilder install \
		--destdir="$pkgdir" \
		--prefix=/usr \
		--libdir=/usr/lib/ocaml

	# Remove annotation files.
	rm "$pkgdir"/usr/lib/ocaml/$_pkgname/*.cmt

	# Contains just a readme and changelog.
	rm -Rf "$pkgdir"/usr/doc
}

dev() {
	default_dev
	depends="$pkgname=$pkgver-r$pkgrel"
	local sitelib="usr/lib/ocaml/$_pkgname"

	cd "$pkgdir"/$sitelib

	mkdir -p "$subpkgdir"/$sitelib
	mv *.cmx *.cmxa *.ml "$subpkgdir"/$sitelib/
}

sha512sums="2e709fee6ceb54463c3989a90aed351c5b48f7a5edce9ccbba4d163cbfb795a19393be0d75885e762d4609961a64e273bb298b94bd3858dc2c20de9396b655d3  ocaml-result-1.4.tar.gz"
